/******************************************************************************/
/*                                                                            */
/*  Copyright (c) 2007-2009: ngi-central.org                                  */
/*  All rights reserved.                                                      */
/*                                                                            */
/******************************************************************************/


/// \file
/// This file implements angle conversions from degrees to radians and vice 
/// versa.

#ifndef __sgl_radians_degrees_h__
#define __sgl_radians_degrees_h__

#include <sgl/global_settings.h>
#include <sgl/conditions.h>
#include <sgl/real_concept.h>
#ifndef _USE_MATH_DEFINES
	#define _USE_MATH_DEFINES
	#define __I_DEFINED_USE_MATH_DEFINES__
#endif
#include <math.h>

namespace sgl {

/******************************************************************************/
/*                                                                            */
/* radians                                                                    */
/*                                                                            */
/******************************************************************************/

template <
	/// The data type. Only floating point types are useful.
	typename T>
/// Convert an angle from degrees to radians.
//!
//! An angle in degrees is converted to radians by multiplying it with pi/180.
//!
//! \return The angle in radians.
inline T radians(
	/// An angle in degrees.					
	T const& degrees)
{
	// Only real types qualify for type T. If this line triggers an error,
	// type T is not a real type.
	BOOST_CONCEPT_ASSERT((sgl::real_concept<T>));

	return degrees * T(M_PI) / T(180);
}


/******************************************************************************/
/*                                                                            */
/* degrees                                                                    */
/*                                                                            */
/******************************************************************************/

template <
	/// The data type. Only floating point types are useful.
	typename T>
/// Convert an angle from radians to degrees.
//!
//! An angle in radians is converted to degrees by multiplying it with 180/pi.
//!
//! \return The angle in degrees.
inline T degrees(
	/// An angle in radians.					
	T const& radians)
{
	// Only real types qualify for type T. If this line triggers an error,
	// type T is not a real type.
	BOOST_CONCEPT_ASSERT((sgl::real_concept<T>));

	return radians * T(180) / T(M_PI);
}

} // namespace sgl

#ifdef __I_DEFINED_USE_MATH_DEFINES__
	#undef _USE_MATH_DEFINES
	#undef __I_DEFINED_USE_MATH_DEFINES__
#endif

#endif // __sgl_radians_degrees_h__
